package com.qingyun.customview.hencode.practice1.views

import android.content.Context
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.view.View

class Practice1DrawCircleView @JvmOverloads constructor(
    context: Context,
    attrs: android.util.AttributeSet? = null,
    defStyleAttr: Int = 0,
) : View(context, attrs, defStyleAttr) {
    private val paint = Paint().apply {
        isAntiAlias = true
        color = Color.BLACK
    }

    override fun onDraw(canvas: Canvas) {
        super.onDraw(canvas)

        paint.style = Paint.Style.FILL
        canvas.drawCircle(200f, 150f, 120f,paint)

        paint.run {
            style = Paint.Style.STROKE
            strokeWidth = 4f
        }
        canvas.drawCircle(500f, 150f, 120f,paint)

        paint.style = Paint.Style.FILL_AND_STROKE
        paint.color = Color.BLUE
        paint.strokeWidth = 10f
        canvas.drawCircle(200f, 430f, 120f,paint)

        paint.style = Paint.Style.STROKE
        paint.strokeWidth=20f
        paint.color = Color.BLUE
        canvas.drawCircle(500f, 430f, 120f,paint)

    }
}